x86/tlb: introduce a flush HVM ASIDs flag
authorRoger Pau Monné <roger.pau@citrix.com>
Wed, 29 Apr 2020 07:04:40 +0000 (09:04 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 29 Apr 2020 07:04:40 +0000 (09:04 +0200)
commit3174835ba825427ab49177ef710657a226fdab01
tree8b31edf2eb913061e2d03c9e3f8806504fe93cbe
parent4ec07971f1c5a236a0d8c528d806efb6bfd3d1a6
x86/tlb: introduce a flush HVM ASIDs flag

Introduce a specific flag to request a HVM guest linear TLB flush,
which is an ASID/VPID tickle that forces a guest linear to guest
physical TLB flush for all HVM guests.

This was previously unconditionally done in each pre_flush call, but
that's not required: HVM guests not using shadow don't require linear
TLB flushes as Xen doesn't modify the pages tables the guest runs on
in that case (ie: when using HAP). Note that shadow paging code
already takes care of issuing the necessary flushes when the shadow
page tables are modified.

In order to keep the previous behavior modify all shadow code TLB
flushes to also flush the guest linear to physical TLB if the guest is
HVM. I haven't looked at each specific shadow code TLB flush in order
to figure out whether it actually requires a guest TLB flush or not,
so there might be room for improvement in that regard.

Also perform ASID/VPID flushes when modifying the p2m tables as it's a
requirement for AMD hardware. Finally keep the flush in
switch_cr3_cr4, as it's not clear whether code could rely on
switch_cr3_cr4 also performing a guest linear TLB flush. A following
patch can remove the ASID/VPID tickle from switch_cr3_cr4 if found to
not be necessary.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
xen/arch/x86/flushtlb.c
xen/arch/x86/mm/hap/hap.c
xen/arch/x86/mm/hap/nested_hap.c
xen/arch/x86/mm/p2m-pt.c
xen/arch/x86/mm/paging.c
xen/arch/x86/mm/shadow/common.c
xen/arch/x86/mm/shadow/hvm.c
xen/arch/x86/mm/shadow/multi.c
xen/include/asm-x86/flushtlb.h